<template>
	<div class="des-box">
		<el-descriptions title="代理信息" size="medium" :border="true">
			<el-descriptions-item label="用户名">{{showData.name}}</el-descriptions-item>
			<el-descriptions-item label="手机号">{{showData.mobile}}</el-descriptions-item>
			<el-descriptions-item label="联系人">{{showData.link_man}}</el-descriptions-item>
			<el-descriptions-item label="代理费率">
				<el-tag size="small">{{showData.rate}}</el-tag>
			</el-descriptions-item>
			<el-descriptions-item label="账户金额">
				<el-tag size="small">{{showData.money}}</el-tag>
				<el-button type="primary" size="mini" style="margin-left: 50px;" @click = "rawal">提现</el-button>
			</el-descriptions-item>
		</el-descriptions>
		<div>
			<el-dialog
			  title="提示"
			  :visible.sync="dialogVisible"
			  width="30%">
			 <el-input
			   placeholder="请输入内容"
			   v-model="money"
			   clearable>
			 </el-input>
			  <span slot="footer" class="dialog-footer">
			    <el-button @click="dialogVisible = false">取 消</el-button>
			    <el-button type="primary" @click="confirm">确 定</el-button>
			  </span>
			</el-dialog>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				agentID: this.$store.state.userId ? this.$store.state.userId : JSON.parse(window.localStorage.userInfo).userId,
				showData: {},
				money : 100,
				dialogVisible: false
			}
		},
		created() {
			let that = this;
			that.$axios({
				url: "/admin/agent/getAgentInfo",
				method: "POST",
				data: {
					agentID: that.agentID
				},
				success(res) {
					if (res.data.code == 200) {
						that.showData = res.data.content
					}
				}
			});
		},
		methods: {
			rawal(){
				this.dialogVisible = true;
			},
			confirm(){
				if(this.money < 100){
					this.$message({
						message : '提现金额不能小于100元！',
						type : 'warning'
					});
					this.dialogVisible = false;
				}else{
					let that = this;
					that.$axios({
						url : "/admin/agent/drawal",
						method : "POST",
						data : {
							agentID : that.agentID,
							money : that.money,
						},
						success(res){
							that.dialogVisible = false;
							if(res.data.code == 200){
								console.log(22);
								that.dialogVisible = false;
								that.$message({
									message: '提现成功！请等待平台打款',
									type: 'success'
								});
							}else{
								that.dialogVisible = false;
								that.$message({
									message: res.data.msg,
									type : 'warning'
								});
							}
						}
					});
				}
				
			}
		}
	}
</script>
<style>
	.des-box {
		width: 800px;
	}
</style>
